package com.ruoyi.web.controller.app;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.WcContentExamine;
import com.ruoyi.system.domain.WcContentExamineAncillary;
import com.ruoyi.system.domain.vo.business.WcContentExamineDetailVO;
import com.ruoyi.system.domain.vo.business.WcContentExamineSaveVO;
import com.ruoyi.system.domain.vo.business.WcContentExamineSelectListDto;
import com.ruoyi.system.domain.vo.business.WcContentExamineSelectListVO;
import com.ruoyi.system.service.IWcContentExamineAncillaryService;
import com.ruoyi.system.service.IWcContentExamineService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 影片内容审查Controller
 *
 * @author ruoyi
 * @date 2024-02-28
 */
@Controller
@Api(tags = {"(app)影片内容审查"})
@RequestMapping("/app/system/wcContentExamine")
public class AppwcContentExamineController extends BaseController {

    @Autowired
    private IWcContentExamineService wcContentExamineService;

    @Autowired
    private IWcContentExamineAncillaryService ancillaryService;

    /**
     * 查询影片内容审查列表
     */
    @ApiOperation("查询影片内容审查列表")
    //@RequiresPermissions("system:application:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WcContentExamineSelectListDto dto) {
//        startPage();
//        if (dto.getStatus() != -1) {
//            dtoc.setSendUserId(getUserId().toString());
//        }
        Page<WcContentExamineSelectListVO> list = wcContentExamineService.getList(dto);
        return getDataTable(list.getRecords());
    }



    /**
     * 新增保存影片内容审查
     */
    @ApiOperation("(app)新增影片内容审查")
    //@RequiresPermissions("system:application:add")
    @Log(title = "(app)影片内容审查", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(@RequestBody WcContentExamineSaveVO saveVO) {
        try {
            wcContentExamineService.addOrUpdateSave(saveVO,saveVO.getWcContentExamine().getId());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return success();
    }
    /**
     * 新增保存影片内容审查
     */
    @ApiOperation("(app)新增影片内容审查")
    //@RequiresPermissions("system:application:add")
    @Log(title = "(app)影片内容审查", businessType = BusinessType.INSERT)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(@RequestBody WcContentExamineSaveVO saveVO) {
        try {
            wcContentExamineService.addOrUpdateSave(saveVO,null);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return success();
    }

    /**
     * 影片内容审查详情
     */
    @ApiOperation("影片内容审查详情")
    //@RequiresPermissions("system:application:edit")
    @GetMapping("/getById/{id}")
    @ResponseBody
    public AjaxResult edit(@PathVariable("id") Long id) {
        WcContentExamineDetailVO vo = wcContentExamineService.selectWcContentExamineDetailVOById(id);
        return success(vo);
    }
    @ApiOperation("删除影片内容审查")
    //@RequiresPermissions("system:application:remove")
    @Log(title = "影片内容审查", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(Long id) {
        //删除附件
        ancillaryService.remove(Wrappers.lambdaQuery(WcContentExamineAncillary.class).
                eq(WcContentExamineAncillary::getWcContentExamineId,id));
        return toAjax(wcContentExamineService.removeById(id));
    }


}
